package com.myblog.common.lang;

import lombok.Data;
import lombok.Getter;
import lombok.Setter;

import java.io.Serializable;

/**
 * 统一返回结果状态
 */
@Data
public class Result implements Serializable {
  private int code;
  private String msg;
  private Object data; // 结果数据
  public static Result succ(Object data){
      return succ(200,"操作成功",data);
  }
  public static Result succ(int code,String msg, Object data){
        Result m = new Result();
        m.setData(data);
        m.setMsg(msg);
        m.setCode(code);
        return m;
    }
    public static Result fail(String msg){

        return fail(400,msg,null);
    }
    public static Result fail(int code,String msg,Object data){
        Result m = new Result();
        m.setCode(code);
        m.setData(data);
        m.setMsg(msg);
        return m;
    }


}
